package com.cx.mall.demo.controller;

import com.cx.mall.common.utils.ResponseVO;
import com.cx.mall.demo.model.UserInfo;
import com.cx.mall.demo.service.IDemoUserInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/userInfo")
public class DemoUserInfoController {
    @Autowired
    private IDemoUserInfoService userInfoService;

    @GetMapping("/getById")
    public ResponseVO getById(long id) {
        UserInfo userInfo = userInfoService.getById(id);
        return ResponseVO.success(userInfo);
    }

    @GetMapping("/listAll")
    public ResponseVO getAll() {
        //调用业务层
        List<UserInfo> list = userInfoService.list();
        return ResponseVO.success(list);
    }

}
